//
//  DeviceModel.h
//  Fotile
//
//  Created by AllenKwok on 16/5/24.
//  Copyright © 2016年 xlink.cn. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "PacketModel.h"
//#import "CookingPromptsInfoModel.h"
#import "XLDeviceEntity.h"

// add for test
#import "FTSmartTypes.h"

@interface DeviceModel : NSObject
#pragma mark - 设备实体（DeviceEntity）信息
/** pid */
@property (copy, nonatomic) NSString *productId;
/** macData */
@property (copy, nonatomic) NSData *macData;
/** mac */
@property (copy, nonatomic) NSString *mac;
/** deviceId */
@property (assign, nonatomic) NSUInteger deviceId;
/** 版本号 */
@property (assign, nonatomic) NSUInteger version;
/** 设备授权码*/
@property (strong, nonatomic) NSNumber *accessKey;
/** 设备订阅码*/
@property (strong, nonatomic) NSNumber *subKey;
/** 设备实体*/
@property (strong, nonatomic) XLDeviceEntity *deviceEntity;
#pragma mark - 设备信息
/** 设备名*/
@property (strong, nonatomic, readonly) NSString *name;
/** 设备权限 0-管理员 1-家庭成员*/
@property (strong, nonatomic) NSNumber *role;
/** 设备是否被订阅*/
@property (strong, nonatomic) NSNumber *isSubscription;
/** 设备是否被添加到家庭*/
@property (strong, nonatomic) NSNumber *isAddHome;
/** 设备类型*/
@property (assign, nonatomic) DeviceType type;
/** 套系类型*/
@property (assign, nonatomic) DeviceSameModelType deviceSuitType;
/** 上传版本号*/
@property (assign, nonatomic) NSUInteger uploadVersion;
/** 固件版本*/
@property (nonatomic,copy) NSNumber *firmwareVersion;
/** 设备权限*/
@property (strong, nonatomic) NSString *authority;
/** 添加日期的时间戳*/
@property (assign, nonatomic) NSTimeInterval addDate;
/** 最后一次使用日期的时间戳*/
@property (assign, nonatomic) NSTimeInterval lastUseDate;
/** 是否允许智能烹饪 */
@property (assign,nonatomic)BOOL allowSmartCook;
/** 是否是虚拟设备*/
@property (assign,nonatomic)BOOL isVirtualDevice;
/** 是否正在烹饪 default is NO */
@property (nonatomic, assign) BOOL isCooking;
/** 是否正在在智能烹饪中 default is NO */
@property (nonatomic, assign) BOOL isSmartCooking;
/** 是否正在在本地烹饪中 default is NO */
@property (nonatomic, assign) BOOL isLocalCooking;

/** 是否是在网关下面订阅，在网关下面为YES, 原有流程为NO*/
@property (assign, nonatomic, getter = IKCCSubscription) BOOL isIKCCSubscription;
/** 数据控制指令长度*/
@property (assign, nonatomic, readonly) uint8_t deviceControlDataLength;

#pragma mark - 设备附加信息
/** 用户图标图片名称*/
@property (copy, nonatomic) NSString *iconName;
/** 闪动图片名称*/
@property (copy, nonatomic) NSString *flashImageName;
/** 创建菜谱的Icon*/
@property (copy, nonatomic) NSString *cookbookIconName;
/** 创建菜谱的Icon*/
@property (copy, nonatomic) NSString *bgImageName;
/** 录制智能菜谱的背景图片*/
@property (copy, nonatomic) NSString *cbGgImageName;

#pragma mark - 设备烹饪相关信息
/** 正在烹饪的菜谱ID*/
@property (copy, nonatomic) NSString *curCookbookID;
/**
 *  菜谱录制状态位
 *  高4位表示录制：1-未录制，2-正在录制，3-异常终止……
 *  低四位表示播放：1-未播放，2-正在播放，3-异常终止……
 */
@property (assign, nonatomic) uint8_t cookbookRecordStatus;
/**
 *  菜谱播放当前步骤
 */
@property (assign, nonatomic) uint8_t cookbookPlayStep;

@property (assign, nonatomic) uint8_t localId;

/**
 *  提示点信息标题
 */
@property (strong, nonatomic) NSMutableArray *markerTitleArray;
/** 烹饪过程提示信息<CookingPromptsInfoModel>*/
@property (strong, nonatomic) NSMutableArray *promptsInfoArray;
/** 智能烹饪的设备code*/
@property (copy, nonatomic) NSData *autoExec;
/** 设备当前状态 */
@property (assign, nonatomic) DeviceStutus deviceStatus;
/** 设备当前状态描述 */
@property (copy, nonatomic) NSString *deviceStatusString;

/** 子设备在线状态，给网关用*/
@property (assign, nonatomic) NSInteger subDeviceStatus;

#pragma mark - 网关子设备返回的新增属性
/** 子设备Mac字节长度 */
@property (nonatomic,assign) UInt8 macLength;

#pragma mark - 方法
#pragma mark -

/**
 *  初始化设备
 *
 *  @return 设备
 */
- (instancetype)init;

/**
 *  根据PID初始化设备
 *
 *  @param pid pid
 *
 *  @return 设备
 */
- (instancetype)initWithProductID:(NSString *)pid;


/**
 *  设置设备的名称
 *
 *  @param name 名称
 */
- (void)setDeviceName:(NSString *)name;

/**
 *  根据协议把接收到的内容给设备的属性赋值
 *
 *  @param payload 接收到的内容
 */
- (void)initWithPayload:(NSData *)payload;

/**
 *  设置菜谱id
 *
 *  @param data 菜谱id值
 */
- (void)setCurCookbookIDWithData:(NSData *)data;

///通过网关返回的子设备数据初始化一个子设备
- (instancetype)initWithGatewayRecvData:(NSData *)data;

#pragma mark - 设备基本控制
/**
 *  查询设备属性
 */
- (void)queryDeviceProperty;

/**
 *  打开
 */
- (void)turnOn;

/**
 *  关闭
 */
- (void)turnOff;

/**
 *  暂停
 */
- (void)pause;

/**
 *  重新开始
 */
- (void)resume;

/**
 *  取消任务
 */
- (void)cancelTask;

#pragma mark - 菜谱录制
/**
 *  开始菜谱录制
 *
 *  @param cookbookId  菜谱id
 */
- (void)startCookbookRecordWithCookbookId:(NSString *)cookbookId;

/**
 *  结束菜谱录制
 */
-(void)stopCookbookRecordWithCookbookId:(NSString *)cookbookId;

/**
 *  取消菜谱录制
 */
-(void)cancelCookbookRecordWithCookbookId:(NSString *)cookbookId;

/**
 *  上传录制菜谱
 *
 *  @param cookbookId  菜谱id
 */
- (void)uploadCookbookDataWithCookbookId:(NSString *)cookbookId;

/**
 *  下载录制菜谱
 *
 *  @param cookbookId 菜谱id
 *  @param data       菜谱数据
 */
- (void)downloadCookbookDataWithCookbookId:(NSString *)cookbookId withCookbookData:(NSData *)data;

/**
 *  开始本地菜谱播放
 *
 *  @param cookbookId 云端菜谱ID
 *  @param localId    本地菜谱ID
 *  @param prama      本地菜普属性值
 */
- (void)startLocalCookbookWithCookbookId:(NSString *)cookbookId withLocalId:(uint16_t)localId withPrama:(uint32_t)prama;



/**
 *  开始灶具的菜谱录制
 *
 *  @param cookbookId 菜谱id
 *  @param cookerNum  左右灶标志：0-左灶，1-右灶
 */
- (void)startCookerCookbookRecordWithCookbookId:(NSString *)cookbookId withCooker:(uint8_t)cookerNum;

/**
 *  开始灶具的菜谱播放
 *
 *  @param cookbookId 菜谱id
 *  @param cookerNum  左右灶标志：0-左灶，1-右灶
 */
- (void)startCookerCookbookPlayWithCookbookId:(NSString *)cookbookId withCooker:(uint8_t)cookerNum;

/**
 *  结束灶具的菜谱播放
 *
 *  @param cookbookId 菜谱id
 *  @param cookerNum  左右灶标志：0-左灶，1-右灶
 */
- (void)stopCookerCookbookPlayWithCookbookId:(NSString *)cookbookId withCooker:(uint8_t)cookerNum;

/**
 *  确认菜谱录制/播放
 *
 *  @param cookbookId 菜谱id
 */
- (void)confirmCookerCookbookRecordWithCookbookId:(NSString *)cookbookId;

/**
 *  添加标记点
 *
 *  @param cookbookId 菜谱id
 *  @param index      index
 */
- (void)addPromptsWithCookbookId:(NSString *)cookbookId withIndex:(uint8_t)index;

/**
 *  改变菜谱步骤
 *
 *  @param cookbookId 菜谱id
 *  @param step       步骤
 *  @param cookerNum  左右灶标志：0-左灶，1-右灶
 */
- (void)playCookbookWithCookbookId:(NSString *)cookbookId  withStep:(uint8_t)step withCooker:(uint8_t)cookerNum;

#pragma mark - 设备消息推送

/**
 *  APP发送推送内容给设备
 *
 *  @param content 推送内容
 */
- (void)sendNotifyMessageToDeviceWithContent:(NSString *)content;

/**
 *  发送开始烹饪消息
 */
- (void)sendStartCookNotifyMessage;

/**
 *  发送结束烹饪消息
 */
- (void)sendStopCookNotifyMessage;

/**
 *  发送开始预约消息
 */
- (void)sendStartAppointmentNotifyMessage;

/**
 *  发送结束预约消息
 */
- (void)sendStopAppointmentNotifyMessage;

/**
 *  发送修改了设置消息
 */
- (void)sendModifySettingNotifyMessage;


/**
 *  APP发送菜谱推送内容给设备
 *
 *  @param cookbookName 菜谱名
 *  @param content      内容
 */
-(void)sendCookbookNotifyMessageToDeviceWithCookbookName:(NSString *)cookbookName WithContent:(NSString *)content;

/**
 *  启动菜谱录制通知
 *
 *  @param cookbookName 菜谱名
 */
- (void)sendStartCookbookRecordNotifyWithCookbookName:(NSString *)cookbookName;

/**
 *  结束菜谱录制通知
 *
 *  @param cookbookName 菜谱名
 */
- (void)sendStopCookbookRecordNotifyWithCookbookName:(NSString *)cookbookName;

/**
 *  取消菜谱录制通知
 *
 *  @param cookbookName 菜谱名
 */
- (void)sendCancelCookbookRecordNotifyWithCookbookName:(NSString *)cookbookName;

/**
 *  启动菜谱播放通知
 *
 *  @param cookbookName 菜谱名
 */
- (void)sendStartCookbookPlayNotifyWithCookbookName:(NSString *)cookbookName;

/**
 *  结束菜谱播放通知
 *
 *  @param cookbookName 菜谱名
 */
- (void)sendStopCookbookPlayNotifyWithCookbookName:(NSString *)cookbookName;
#pragma mark - 其他功能

/**
 *  跳转到响应设备的主界面
 *
 *  @param navigationController 需要跳转的NavigationController
 */
- (void)pushToMainControllerWithNavigationController:(UINavigationController *)navigationController;

/**
 *  配置虚拟设备全部信息
 *
 *  @param dataPoint 配置信息
 */
- (void)configVirtualAllDeviceWithUint8_t:(uint8_t *)dataPoint;

/**
 *  配置虚拟设备温度，时间
 *
 *  @param dataPoint 配置信息
 */
- (void)configVirtualDeviceWithUint8_t:(uint8_t *)dataPoint;
@end
